package com.xk._04regEx;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @description: 非贪婪匹配
 * @author: xu
 * @date: 2022/11/1 13:45
 */
public class RegExp_09 {
    public static void main(String[] args) {
        String content = "hello111111 ok";
        // \\d+ --> 默认是贪婪匹配[尽可能匹配多的]
        // \\d+? --> 非贪婪匹配[尽可能匹配少的]
        String regStr = "\\d+?";

        Pattern pattern = Pattern.compile(regStr);
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()) {
            System.out.println("找到：" + matcher.group(0));
        }
    }
}
